<!doctype html>
<html>
<head>
    <title>设置</title>
    <?php $this->load->module('admin/index/page_header');?>
    <link href="<?php echo URLPRE;?>static/admin/css/font_icon.css" rel="stylesheet" />
</head>
<body>
<div class="wrap">
    <div class="nav">
        <ul>
            <li class="current"><a href="<?php echo site_url('weixin/admin/send');?>">群发消息</a></li>
            <li><a href="<?php echo site_url('weixin/admin/new_send');?>">新建群发消息</a></li>
        </ul>
    </div>
    <div class="table_full">
        <form class="formvalidate" action="" method="post">
            <div class="h_a">群发消息</div>
            <div class="table_list">
                <table width="100%">
                    <col class="th" />
                    <col/>
                    <tbody>
                    <tr>
                        <th width="50">&nbsp;</th>
                        <th>群发对象</th>
                        <th>消息预览</th>
<!--                        <th>MSG_ID</th>-->
                        <th>状态</th>
                        <th>创建时间</th>
                    </tr>
                    <?php foreach ($list as $row) { ?>
                        <tr>
                            <td class="btn_min">
                                <div class="operat hidden">
                                    <a class="icon-cog action" href="javascript:;">处理</a>
                                    <div class="menu_select">
                                        <ul>
                                            <li><a class="icon-pencil" href="<?php echo site_url('weixin/admin/new_send/?list_id='.$row['id']);?>">编辑</a></li>
                                            <li><a class="icon-remove-2 doDel" href="javascript:;" data-uri="<?php echo site_url('weixin/admin/send_list_delete/?id='.$row['id']);?>">删除</a></li>
                                            <?php if($row['rows']){?>
                                            <li><a class="icon-search" onclick="wx_send(<?php echo $row['id']?>);" href="javascript:;">发送</a></li>
                                            <?php }?>
                                        </ul>
                                    </div>
                                </div>
                            </td>
                            <td><?php echo $row['group_id'] == '-1' ? '全部用户' : $user_group[$row['group_id'] ]['name']?></td>
                            <td>
                                <style>
                                    .item-1,.item{border-bottom: 1px solid #d9d9d9;}
                                    .item-1{background-size:100px auto;height:100px;overflow:hidden;padding:5px;position:relative;display: block;}
                                    .item-1 em, .item-1 span{display:block;position: absolute;bottom:0;left:0;width: 100%;height:30px;line-height:30px;overflow:hidden;}
                                    .item-1 em{background: #000;opacity: .6;}
                                    .item-1 span{color:#fff;z-index:1;padding:0 5px;}
                                    .item{line-height:30px;height:30px;overflow:hidden;padding:5px;}
                                    .item span{float: left}
                                    .item img{float:right;height:30px;width:30px;}
                                </style>
                                <div style="background:#fff">
                                    <ul class="clearfix">
                                        <?php foreach ($row['rows'] as $k => $v) {
                                            if ($k == 0) {
                                                ?>
                                                <li class="item-1" style="background: url(<?php echo URLPIC . $v['thumb'] ?>) no-repeat">
                                                    <span><?php echo $v['title']; ?></span>
                                                    <em></em>
                                                </li>
                                            <?php } else { ?>
                                                <li class="item">
                                                    <span><?php echo $v['title']; ?></span>
                                                    <img src="<?php echo URLPIC . $v['thumb'] ?>">
                                                </li>
                                            <?php
                                            }
                                        }
                                            ?>
                                    </ul>
                                </div>
                            </td>
<!--                            <td>--><?php //echo date('Y-m-d H:i:s', $row['upts'])?><!--</td>-->
                            <td><?php echo $row['msg_id'] ? '已发送' : '未发送'?></td>
                            <td><?php echo date('Y-m-d H:i:s', $row['crts'])?></td>
                        </tr>
                    <?php }?>
<!--                    <tr>-->
<!--                        <th>&nbsp;</th>-->
<!--                        <td colspan="3">-->
<!--                            <a href="--><?php //echo site_url('weixin/admin/new_send');?><!--" class="btn btn_submit J_ajax_submit_btn">新建群发消息</a>-->
<!--                        </td>-->
<!--                    </tr>-->
                    </tbody>
                </table>
            </div>
        </form>
    </div>
</div>
<script type="text/javascript">
    function wx_send(id){
        $.dialog.confirm("你确认发送吗？", function () {
            $.ajax({
                url:'<?php echo site_url('weixin/admin/send_news/?id=')?>' + id,
                cache:false,
                dataType:'json',
                type:'POST',
                data:{},
                success:function(msgObj){
                    if(msgObj.errcode !=0){
                        $.dialog.alert('群发消息失败，消息素材为空，请添加消息素材');
                    }else{
                        $.dialog.alert('发送成功！');
                    }
                    return false;
                }
            });
            return true;
        }, function () {
            return true;
        })
    }
</script>
</body>
</html>